#include<iostream>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
char n[11]={"0123456789"};
char n1[11]={'0'},n2[11]={'0'},n3[11]={'0'};
int l(int x)
{
	int len=0;
	while(x)
	{
		x/=10;
		len++;
	}
	return len;
}
int main()
{
	
	int num,len,temp,i,j,k=0;
	double result,t;
	int a,b,c;
	scanf("%d",&num);
	len=l(num);
	//printf("%d\n",len);
	//sort(n,n+10);
	do
	{
		a=0;b=0;c=0;
		for(i=1;i<=8;i++)
		{
			for(j=1;j<10-i;j++)
			{
				strncpy(n1,n,i);
				n1[i]='\0'; 
				strncpy(n2,n+i,j);
				n2[j]='\0'; 
				strncpy(n3,n+i+j,(10-i-j));
				n3[10-i-j]='\0';
				if(n1[0]=='0'||n2[0]=='0'||n3[0]=='0')
					if(n1[1]!='\0'||n2[1]!='\0'||n3[1]!='\0')
						continue;
				if(n3[0]=='0'&&n3[1]=='\0')
					continue;
				
				for(i=0;i<strlen(n1);i++)
				{
					a+=(n1[i]-'0');
					if(i!=strlen(n1)-1)
						a*=10;
				}
				if(l(a)>len)
					continue;
				
				for(i=0;i<strlen(n2);i++)
				{
					b+=(n2[i]-'0');
					if(i!=strlen(n2)-1)
						b*=10;
				}
				for(i=0;i<strlen(n3);i++)
				{
					c+=(n3[i]-'0');
					if(i!=strlen(n3)-1)
						c*=10;
				}
				result=a+(double)b/c;
				t=result>num?(result-num):(num-result);
				if( t <1 )
					k++;
			}
		}
	}while(next_permutation(n,n+10));
	printf("%d\n",k);
	return 0;
}
